# escape=`
FROM  mcr.microsoft.com/windows:20H2

SHELL ["cmd", "/S", "/C"]

# Donwload version 17.2.9 from Microsoft (https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-history#release-dates-and-build-numbers)
RUN curl -SL --output vs_buildtools.exe https://download.visualstudio.microsoft.com/download/pr/d66ab022-583e-4b0b-998b-d60f5173aa4e/569d70493499d754edca8dee5d0c2a16dbfc17b9382e68fbc1e07f29061d8d38/vs_BuildTools.exe
RUN start /w vs_buildtools.exe --quiet --wait --norestart --nocache`
	--add Microsoft.VisualStudio.Workload.VCTools;includeRecommended`
	--add Microsoft.VisualStudio.Component.VC.Llvm.Clang`
	--add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools`
	&& del /q vs_buildtools.exe

# Installing chocolatey AFTER the vs buildtools.
RUN powershell Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
RUN choco install -y cmake --version=3.21.3 --installargs 'ADD_CMAKE_TO_PATH=System' && `
	choco install -y pwsh && `
	choco install -y git --version=2.33.0.2 && `
	choco install -y doxygen.install --version=1.9.0 && `
	choco install -y graphviz --version=2.49.1 && `
	choco install -y wget --version=1.21.2 && `
	choco install -y openssl --version=1.1.1.1100

# Copy and register virtual GenTL producer for testing
RUN mkdir "C:\Tools\viky"
COPY ./viky C:\Tools\viky
ENV GENICAM_GENTL64_PATH="C:\Tools\viky"

ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
CMD [ "pwsh.exe" ]
